#include "IcmEVCalculator.h"
#include "windows.h"
#include "ezlogger_headers.hpp"

double CalculateIcmEV(int* aStackArr)
{	
	EZLOGGERSTREAM << "====================================="<< std::endl;
	for(int i=0;i<9;i++)
	{
		EZLOGGERSTREAM << "aStackArr[ "<<i<<"]:"<< aStackArr[i]<< std::endl;
	}
	double totalEV=(aStackArr[USERPOSE]/(double)TOTALCH)*PL1;
	EZLOGGERSTREAM << "totalEV: "<<totalEV<< std::endl;
	double temp=0;
	//second place probability
	for(int i=0;i<9;i++)
	{
		if(i==USERPOSE) continue;
		if(aStackArr[i]==0) continue;
		temp+=(aStackArr[i]/(double)TOTALCH)*(aStackArr[USERPOSE]/(double)(TOTALCH-aStackArr[i]));
	}

	totalEV+=temp*PL2;
	EZLOGGERSTREAM << "totalEV: "<<totalEV<< std::endl;

	temp=0;

//third place probability
	for(int i=0;i<9;i++)
	{
		if(i==USERPOSE) continue;
		for(int j=0;j<9;j++)
		{			
			if(j==USERPOSE) continue;
			if(j==i) continue;
			temp+=(aStackArr[i]/(double)TOTALCH)*(aStackArr[j]/(double)(TOTALCH-aStackArr[i]))*(aStackArr[USERPOSE]/(double)(TOTALCH-aStackArr[i]-aStackArr[j]));
		}
	}
	totalEV+=temp*PL3;
	EZLOGGERSTREAM << "totalEV: "<<totalEV<< std::endl;
	return totalEV;	
}